package cn.wolfcode.controller;

import cn.wolfcode.domain.*;
import cn.wolfcode.query.StrategyQuery;
import cn.wolfcode.service.*;
import cn.wolfcode.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("strategies")
public class StrategyController {
    @Autowired
    private IStrategyThemeService strategyThemeService;
    @Autowired
    private IStrategyService strategyService;
    @GetMapping("detail")
    public Object detail(String id){
        Strategy strategy = strategyService.get(id);
        return JsonResult.success(strategy);
    }

    @GetMapping("query")
    public Object query(StrategyQuery qo){
        Page query = strategyService.query(qo);
        return JsonResult.success(query);
    }
    @GetMapping("themes")
    public Object themes(StrategyQuery qo){
        List<StrategyTheme> list = strategyThemeService.listAll();
        return JsonResult.success(list);
    }

}
